package tech.aistar.service.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.aistar.mapper.services.ServicesListMapper;
import tech.aistar.service.services.IServicesListService;
import tech.aistar.vo.ServicesAndNameQueryVo;

import java.util.List;

/**
 * @Author: lya
 * @Description: 本类的作用描述:
 * @CreateDate: 2019/10/8
 * @Version: 1.0
 */
@Service
public class ServicesListServiceImpl implements IServicesListService{
    @Autowired
    private ServicesListMapper servicesListMapper;

    /**
     * 查询服务和用户昵称
     */
    @Override
    public List<ServicesAndNameQueryVo> findServicesAndName() {
        List<ServicesAndNameQueryVo> list = servicesListMapper.findServicesAndName();
        return list;
    }

    @Override
    public PageInfo<ServicesAndNameQueryVo> findAll(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);

        List<ServicesAndNameQueryVo> pageList = servicesListMapper.findServicesAndName();

        PageInfo<ServicesAndNameQueryVo> pageInfo = new PageInfo<>(pageList);
        return pageInfo;
    }


    /**
     * 根据服务名称模糊查询
     */
    @Override
    public List<ServicesAndNameQueryVo> findServicesByName(String title) {
        List<ServicesAndNameQueryVo> list = servicesListMapper.findServicesByName(title);
        return list;
    }

    /**
     * 根据类别查询
     */
    @Override
    public List<ServicesAndNameQueryVo> findServicesByCategory(Integer categoryId) {
        List<ServicesAndNameQueryVo> list = servicesListMapper.findServicesByCategory(categoryId);
        return list;
    }

    /**
     * 根据详细类别查询
     */
    @Override
    public List<ServicesAndNameQueryVo> findServicesByCategoryDetail(Integer categorydetailId) {
        List<ServicesAndNameQueryVo> list = servicesListMapper.findServicesByCategoryDetail(categorydetailId);
        return list;
    }

    /**
     * 根据成交数降序排序
     */
    @Override
    public List<ServicesAndNameQueryVo> findServicesByCount() {
        List<ServicesAndNameQueryVo> list = servicesListMapper.findServicesByCount();
        return list;
    }

    /**
     * 根据发布时间降序排序
     */
    @Override
    public List<ServicesAndNameQueryVo> findServicesBybeginTime() {
        List<ServicesAndNameQueryVo> list = servicesListMapper.findServicesBybeginTime();
        return list;
    }

    /**
     * 根据价格降序排序
     */
    @Override
    public List<ServicesAndNameQueryVo> findServicesByPriceDesc() {
        List<ServicesAndNameQueryVo> list = servicesListMapper.findServicesByPriceDesc();
        return list;
    }

    /**
     * 根据价格升序排序
     */
    @Override
    public List<ServicesAndNameQueryVo> findServicesByPrice() {
        List<ServicesAndNameQueryVo> list = servicesListMapper.findServicesByPrice();
        return list;
    }

    /**
     * 根据价格区间查询(不好使)
     */
    @Override
    public List<ServicesAndNameQueryVo> findServicesByPriceRange(Double minPrice, Double maxPrice) {
        List<ServicesAndNameQueryVo> list = servicesListMapper.findServicesByPriceRange(minPrice,maxPrice);
        return list;
    }
}
